﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sealight.Core.Common;
using Sealight.Core.DataAdapter;

namespace Sealight.Core.Domain
{
  public  class DiscountEntity:BaseEntity
    {
        /// <summary>
        /// Gets or sets the discount identifier
        /// </summary>
        public virtual int DiscountID { get; set; }

        /// <summary>
        /// Gets or sets the discount type identifier
        /// </summary>
        public virtual DiscountType DiscountType { get; set; }

        /// <summary>
        /// Gets or sets the discount requirement identifier
        /// </summary>
        public virtual DiscountRequirementEntity DiscountRequirement { get; set; }

        /// <summary>
        /// Gets or sets the discount limitation identifier
        /// </summary>
        public virtual DiscountLimitationEntity DiscountLimitation { get; set; }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to use percentage
        /// </summary>
        public virtual bool UsePercentage { get; set; }

        /// <summary>
        /// Gets or sets the discount percentage
        /// </summary>
        public virtual decimal DiscountPercentage { get; set; }

        /// <summary>
        /// Gets or sets the discount amount
        /// </summary>
        public virtual decimal DiscountAmount { get; set; }

        /// <summary>
        /// Gets or sets the discount start date and time
        /// </summary>
        public virtual DateTime StartDate { get; set; }

        /// <summary>
        /// Gets or sets the discount end date and time
        /// </summary>
        public virtual DateTime EndDate { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether discount requires coupon code
        /// </summary>
        public virtual bool RequiresCouponCode { get; set; }

        /// <summary>
        /// Gets or sets the coupon code
        /// </summary>
        public virtual string CouponCode { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity has been deleted
        /// </summary>
        public virtual bool Deleted { get; set; }

        public virtual discount ToDataAdapter()
        {
            discount data = new discount
            {
                name = this.Name,
                coupon_code = this.CouponCode,
                deleted = this.Deleted,
                discount_amount = this.DiscountAmount,
                discount_percentage = this.DiscountPercentage,
                discount_type = this.DiscountType,
                id = this.DiscountID,
                end_date = this.EndDate,
                requires_coupon_code = this.RequiresCouponCode,
                start_date = this.StartDate,
                use_percentage = this.UsePercentage,
                discount_limitation = this.DiscountLimitation!= null?this.DiscountLimitation.ToDataAdapter():null,
                discount_requirement = this.DiscountRequirement != null ? this.DiscountRequirement.ToDataAdapter():null

            };

            return data;
        }
    }
}
